package cn.damai.backstage.service.impl;

import cn.damai.backstage.mapper.UserMapper;
import cn.damai.backstage.model.User;
import cn.damai.backstage.service.UserService;
import cn.damai.util.PasswordEncrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User queryByUser(User user) {
        User u = userMapper.queryByUser(user.getUsername());
        if(PasswordEncrypt.authenticatePassword(u.getPassword(),user.getPassword())){
            return u;
        }else {
            return null;
        }

    }
}
